package com.yxw.springmvc.test;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created by hp on 2016/8/1.
 */
@Controller
public class ControllerTest1 {
    @RequestMapping(value={"ctest1","ctest2"})
    public String index(){
        return "hello";
    }

    @RequestMapping(value = {"ctest3"})
    public String index2(){
        return "hello";
    }

    @RequestMapping(value = {"ctest4/{name}"})
    public String index3(@PathVariable("name") String name, Model model){
        model.addAttribute("name",name);
        return "hello";
    }

    @RequestMapping(value = {"ctest5/{name}/ids/{id}"})
    public String index4(@PathVariable("name") String name,@PathVariable("id") int id,Model model){
        model.addAttribute("name",name);
        return "hello";
    }

    @RequestMapping(value = {"ctest/get"},method = RequestMethod.GET)
    public String index5(Model model){
        model.addAttribute("name","get");
        return "hello";
    }
}
